package com.itheima.web.controller.front;


import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.itheima.core.BaseServlet;
import com.itheima.core.ResponseBody;
import com.itheima.domain.front.ExamQuestion;
import com.itheima.domain.store.Question;
import com.itheima.service.front.ExamService;
import com.itheima.service.front.impl.ExamServiceImpl;
import com.itheima.web.controller.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/exam/*")
public class ExamServlet extends BaseServlet {
    private ExamService examService = new ExamServiceImpl();
    @ResponseBody
    public Result getPaper(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Question> questionList = examService.getPaper();
        return new Result("试卷生成成功！", questionList);
    }

    @ResponseBody
    public Result deleteExaminationPaper(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("id");
        examService.deleteById(id);

        return new Result("删除成功",true);
    }
}